﻿/** Copyright © 2013-2015 Vahid Jalili
 * 
 * This file is part of MuSERA project.
 * MuSERA is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 * MuSERA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with Foobar. If not, see http://www.gnu.org/licenses/.
 **/

using Polimi.DEIB.VahidJalili.MuSERA.ViewModels;
using System;
using System.Windows.Input;

namespace Polimi.DEIB.VahidJalili.MuSERA.Commands
{
    internal class NNDCommand : ICommand
    {
        // Parameters are : 0 sessionsViewModel.di3.status
        //                  1 sessionsViewModel.selectedSampleID

        public event EventHandler CanExecuteChanged
        {
            /// to wire back to WPF command system
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }
        public bool CanExecute(object parameter)
        {
            if (parameter == null || ((object[])parameter).Length != 2 || ((object[])parameter)[0] == null || ((object[])parameter)[1] == null) return false;
            return (double)((object[])parameter)[0] == 100 ? true : false;
        }
        public void Execute(object parameter)
        {
            uint selectedSampleID = Convert.ToUInt32((string)((object[])parameter)[1]);
            ApplicationViewModel.Default.sessionsViewModel.di3.NNDD.CalculateNNDD(selectedSampleID); // TODO : when selected sample ID from sessionDetailsViewModel is updated to UInt32, this line has to be updated as well.
        }
    }
}
